package com.chapp.util;

import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.chapp.R;
import com.chapp.base.Venue;
import com.chapp.provider.handler.VenueHandler;
import com.chapp.ui.ArtistVenue;

public class VenueFavoriteHandler extends Activity {

	ListView list;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tabs_favorits);
		list = (ListView) findViewById(R.id.favorits_list);
		list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				Intent goArtist = new Intent(VenueFavoriteHandler.this,
						ArtistVenue.class);
				goArtist.putExtra("item",
						(Venue) parent.getItemAtPosition(position));
				startActivity(goArtist);
			}
		});
		fillList();
	}

	@Override
	protected void onResume() {
		super.onResume();
		fillList();
	};

	public void fillList() {
		List<Venue> list_event = VenueHandler.getAllVenues(this);
		ListAdapter adapter = new ListAdapter(this, list_event);
		list.setAdapter(adapter);
	}
}
